package cn.com;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class LambdaDemo {
    public static void main(String[] args) {
        new Thread(()->{
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            String s = "集合：%s%s";
            System.out.println(String.format(s,"aa","bb"));}).start();
        ListSort();
        int result = add(5,4,(a,b)->{
            return a*b;
        });
        System.out.println(result);
    }

    public static void ListSort(){
        List<String> arrs = Arrays.asList("aaa","bbb","ccc","ddd");
        Collections.sort(arrs,(a,b)->{
            return b.compareTo(a);
        });
        for (int i = 0; i < arrs.size(); i++) {
            System.out.println(arrs.get(i));
        }
        arrs.forEach(a->{
            System.out.println(a);
        });
    }

    public static int add(int a,int b,OperFunction of){
        return of.function(a,b);
    }
}
